#pragma once

#include "..\Engine\Engine.h"

// Event synchronization
#define MAX_EVENTS 10
#define EVENT_REPORT_PROGRESS			0
#define EVENT_LOADING_DB_FINISHED		1
#define EVENT_TERMINATE					2
#define	EVENT_LOADING_DB_EXIT			3
#define EVENT_LOAD_ENDGAMEDB			4
#define EVENT_ENGINE_START				5
#define EVENT_ENGINE_TERMINATE			6
#define EVENT_ENGINE_FINISHED			7
#define EVENT_ENGINE_EXITED				8
#define EVENT_COMPUTE_MOVE				9

#define ENGINE_EVENT_COUNT				2
#define ENGINE_EVENT_INDEX				5

#define SEARCH_NEGAMAX					1
#define SEARCH_ALPHABETA				2
#define SEARCH_MTDf						3
#define SEARCH_PVS						4
	
// synchronization structure
struct SEngineSynch {
public:
	HANDLE hEvents[MAX_EVENTS];
	HANDLE hProgressMutex;
	int volatile iProgressPercents;
	HANDLE hEngineVarsMutex;
};


void InitEvents(SEngineSynch *pS);
void CloseEvents(SEngineSynch *pS);
void ReportProgressFunction(int percent, void* pData);
DWORD WINAPI BackgroundDBLoader(LPVOID lpThreadParameter);
DWORD WINAPI EngineThread(LPVOID lpThreadParameter);
